// import ReactDOM from 'react-dom';
// import React from 'react';
// import {HashRouter,Route,IndexRoute,Switch} from 'react-router-dom';
// import {Header,NoMatch} from './Components'
// import {routes} from './router/router.config'
// import 'element-theme-default';
// import {Provider} from 'react-redux';
// import store from './store'
// import { getdata } from './action/cart'
// //保存store状态的配置
// // import configureStore from './store';
// import { PersistGate } from 'redux-persist/lib/integration/react'
// // let {store,persistor} = configureStore();
// store.dispatch(getdata())
// ReactDOM.render(
//   // 所有的路由通过store传递
//   <Provider store={store}>
//    {/* <PersistGate loading={null} persistor={persistor}> */}
//     <HashRouter>
//           <div>
//             <Header/>
          
//             <Switch>
//               {
//                 routes.map((route,index)=>
//                 <Route key={index} path={route.path} component={route.component} exact={route.exact}/>
//               )
//               }
//               <Route component={NoMatch} />
//             </Switch>
//           </div>
//         </HashRouter>
//         {/* </PersistGate> */}
//       </Provider>,
//      document.getElementById('app'))



import ReactDOM from 'react-dom';
import React from 'react';
import {HashRouter,Route,IndexRoute,Switch} from 'react-router-dom';
import {Header,NoMatch} from './Components'
import {routes} from './router/router.config'
import 'element-theme-default';
import {Provider} from 'react-redux';
import { getdata } from './action/cart'
import 'antd/dist/antd.css'
import './styles/App.css'
//保存store状态的配置
import configureStore from './store';
import { PersistGate } from 'redux-persist/lib/integration/react'
let {store,persistor} = configureStore();

store.dispatch(getdata())

ReactDOM.render(
  // 所有的路由通过store传递
  <Provider store={store}>
   <PersistGate loading={null} persistor={persistor}>
    <HashRouter>
          <div>
            <Header/>
          
            <Switch>
              {
                routes.map((route,index)=>
                <Route key={index} path={route.path} component={route.component} exact={route.exact}/>
              )
              }
              <Route component={NoMatch} />
            </Switch>
          </div>
        </HashRouter>
        </PersistGate>
      </Provider>,
     document.getElementById('app'))
